package login_log_v1

import (
	"context"
	"gf-xb-api/internal/dao"
	"gf-xb-api/internal/model/do"
	"gf-xb-api/internal/model/entity"

	"github.com/gogf/gf/v2/database/gdb"
	"github.com/gogf/gf/v2/util/gconv"
)

func (s *sLoginLog) Create(ctx context.Context, in do.SysLoginLog) (err error) {

	var data *entity.SysLoginLog
	if err = gconv.Struct(in, &data); err != nil {
		return err
	}

	dao.SysLoginLog.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
		_, err := dao.SysLoginLog.Ctx(ctx).Insert(data)
		if err != nil {
			return err
		}

		return nil
	})

	return nil
}
